﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Http;
using System.Net.Http;
using System.IO;
using System.Net;

namespace PServiceBus.WebAPI.Controllers {
    public class FlashController : ApiController {

        public HttpResponseMessage Get() {
            var filePath = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") 
                + Request.RequestUri.LocalPath.Substring(1);
            if (!File.Exists(filePath)) return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Could not find file!");
            var response = Request.CreateResponse();
            response.Content = new StreamContent(File.Open(filePath, FileMode.Open));
            return response;
        }

    }
}
